package com.feicheng.lanniao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.feicheng.lanniao.entity.CarImage;
import com.feicheng.lanniao.entity.HouseBuyClientVo;
import com.feicheng.lanniao.mapper.CarImageMapper;
import com.feicheng.lanniao.result.ResultInfo;
import com.feicheng.lanniao.service.CarImageService;
import org.springframework.data.convert.EntityWriter;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.sql.SQLException;
import java.sql.Wrapper;
import java.util.List;

/**
 * @Author tianchunlei
 * @Des //车辆小图业务类
 * @Date 2021/9/24
 **/
@Service
public class CarImageServiceImpl extends ServiceImpl<CarImageMapper,CarImage> implements CarImageService{

    @Resource
    private CarImageMapper carImageMapper;

    @Resource
    private CarImageService carImageService;

    /**
     * @Author tianchunlei
     * @Description //批量添加车辆小图的业务方法
     * @Date 2021/9/24 15:37
     * @Param List<CarImage>
     * @return
     */
    @Override
    public ResultInfo batchAdd(List<CarImage> list) {
        carImageService.saveBatch(list);
        return ResultInfo.success();
    }

    /**
     * @Author tianchunlei
     * @Description //批量删除车辆小图的方法
     * @Date 2021/9/24 15:37
     * @Param
     * @return
     */
    @Transactional
    @Override
    public ResultInfo batchDelete(Integer carId) {
        carImageMapper.deleteImageUrls(carId);
        return ResultInfo.success();
    }

    /**
     * @Author tianchunlei
     * @Description //按照车辆id查询车辆小图片的集合
     * @Date 2021/9/26 16:50
     * @Param
     * @return
     */
    @Override
    public ResultInfo selectUrlAll(Integer carId) {
        QueryWrapper<CarImage> queryWrapper = new QueryWrapper<CarImage>();
        queryWrapper.eq("car_id",carId);
        return ResultInfo.success(carImageMapper.selectList(queryWrapper));
    }
}
